<template>
  <div class="maritimeAdd">
    <div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane
          v-for="item in optionsTabs"
          :key="item.name"
          :label="$t(item.label)"
          :name="item.name"
        ></el-tab-pane>
      </el-tabs>
    </div>
    <div style="padding: 0 10px; height: calc(100% - 80px)">
     <keep-alive>
         <component :is="componentMap[activeName]" />
      </keep-alive>
    </div>
  </div>
</template>

<script setup >
import { ref, computed } from "vue";
import { useRouter } from "vue-router";
import entrust from "./entrust.vue";
import goodsDetails from "./goodsDetails.vue";
import containerPickup from "./containerPickup.vue";
import cost from "./cost.vue";

defineOptions({
  name: "MaritimeAdd",
});
// 创建组件映射对象，将字符串名称映射到实际组件
const componentMap = {
  entrust,
  goodsDetails,
  containerPickup,
  cost
};

const activeName = ref("entrust");
const optionsTabs = [
  {
    label: "委托",
    name: "entrust",
  },
  {
    label: "货物明细",
    name: "goodsDetails",
  },
   {
    label: "提柜",
    name: "containerPickup",
  },
  {
    label: "费用",
    name: "cost",
  }
];

const router = useRouter();
const detailed = computed(() => router.currentRoute.value.query.detailed);
</script>

<style scoped lang="scss">
.maritimeAdd {
  width: 100%;
  height: 100%;
  background: #fff;

  .nav-title {
    font-size: 20px;
    color: #333;
    font-weight: 500;
    padding: 15px 10px 10px;
    border-bottom: 1px solid #e4e4e4;
  }
}
</style>